<%--
  Created by IntelliJ IDEA.
  User: 10953
  Date: 2021/1/26
  Time: 15:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>show</title>
</head>
<body>
<h1>记账管理</h1>
<form action="/getAllBills">
    <p>
        类型:
        <select name="typeid">
            <option value="-1">不限</option>
            <c:forEach var="bt" items="${billTypeList}">
                <option value="${bt.id}" ${tid==bt.id?'selected':''}>${bt.name}</option>
            </c:forEach>

        </select>
        时间:
        从 <input type="text" name="begin" value="${begin}"> 到 <input type="text" name="end" value="${end}">
        <input type="submit" value="搜索">
</form>
<input type="button" value="记账" onclick="javascript:location.href='/getBillType'"><br><br>
<table border="1" width="500px" cellspacing="0">
    <tr>
        <th>标题</th>
        <th>记账时间</th>
        <th>类别</th>
        <th>金额</th>
        <th>说明</th>
        <th>操作</th>
    </tr>
    <c:if test="${info.list.size()>0}">
        <c:forEach items="${info.list}" var="bill">
            <tr>
                <td>${bill.title}</td>
                <td><fmt:formatDate value="${bill.billtime}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                <td>${bill.billType.name}</td>
                <td>
                    <c:choose>
                        <c:when test="${bill.billType.name=='支出'||bill.billType.name=='借出'||bill.billType.name=='还出'}">
                            -${bill.price}
                        </c:when>
                        <c:when test="${bill.billType.name=='收入'||bill.billType.name=='借入'||bill.billType.name=='还入'}">
                            +${bill.price}
                        </c:when>
                        <c:otherwise>
                            ${bill.price}
                        </c:otherwise>
                    </c:choose>

                </td>
                <td>${bill.explains}</td>
                <td>
                    <a href="/deleteById?bid=${bill.id}">删除</a>
                    <a href="/findById?bid=${bill.id}">修改</a>
                </td>
            </tr>
        </c:forEach>
    </c:if>
    <c:if test="${info.list.size()==0}">
        <tr>
            <td colspan="6"><h3 align="center">没有找到任何数据</h3></td>
        </tr>
    </c:if>
    <tr>
        <td colspan="6">
            <a href="/getAllBills?typeid=${tid}&begin=${begin}&end=${end}">首页</a>

            <a href="/getAllBills?page=${info.prePage==0?1:info.prePage}&typeid=${tid}&begin=${begin}&end=${end}">上一页</a>

            <a href="/getAllBills?page=${info.nextPage==0?info.pages:info.nextPage}&typeid=${tid}&begin=${begin}&end=${end}">下一页</a>

            <a href="/getAllBills?page=${info.pages}&typeid=${tid}&begin=${begin}&end=${end}">尾页</a>

            总页数:${info.pages}
            总条数:${info.total}
        </td>
    </tr>

</table>
</p>
</body>
</html>
